<?php 
	class module_popularPosts extends module
	{
		public $content;
		public function get_content($name='')
		{
			$content = '';
			$query = "SELECT p.id,p.created_on,p.title FROM posts as p WHERE p.state=1 ORDER BY p.hit DESC LIMIT 0,10";
			$result = mysql_query($query) or die(mysql_error());
			$content = $content.'<ul id="popular-posts-wrapper">';
			while ($row = mysql_fetch_array($result)) {
				$date = date_create($row[created_on]);
				$url = BASEURL.'/index.php?option=com_content&view=article&id='.$row[id];
				$content = $content.'<li><a href="'.$url.'">'.$row[title].'&nbsp;('.date_format($date,'d/m/Y').')</a></li>';
			}
			$content = $content.'</ul>';
			echo $content;
		}
	}
?>